unit UfrmClientSelect;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, WSBrowse, DBGridEhGrouping, DB, ActnList, RzPanel, GridsEh,
  DBGridEh, RzTabs, ExtCtrls, ADODB, RzCommon, RzButton, StdCtrls, Mask,
  RzEdit, RzLabel,WSEdit,ufrmProviderEdit;

type
  TfrmClientSelect = class(TWSBrowseForm)
    qryClient: TADOQuery;
    RzLabel1: TRzLabel;
    RzEdit1: TRzEdit;
    RzButton1: TRzButton;
    RzToolButton1: TRzToolButton;
    procedure DBGridEhDblClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure RzButton1Click(Sender: TObject);
  private
     FClientType:string;
     FClientID:integer;
  protected
    procedure iniForm; override;
    function CreateEditForm: TWSEditForm; override;

  public
    property ClientType:string  read FClientType write FclientType;
    property ClientID:integer read FClientID;
    procedure  ShowClient;
  end;

var
  frmClientSelect: TfrmClientSelect;

implementation

uses CommonDM;

{$R *.dfm}

{ TfrmClientSelect }

procedure TfrmClientSelect.iniForm;
begin
  inherited;
  
end;

procedure TfrmClientSelect.DBGridEhDblClick(Sender: TObject);
begin
 // inherited;
  FClientID:=DataSet.Fields[0].AsInteger;
  Close;
end;

procedure TfrmClientSelect.ShowClient;
begin
  qryClient.Close;
  qryClient.SQL.Clear;
  qryClient.SQL.Text:='select * from tb_client where clienttype=:clienttype';
  qryClient.Parameters.ParamByName('clienttype').Value:=FClientType;
  qryClient.Open;
end;

procedure TfrmClientSelect.FormShow(Sender: TObject);
begin
  inherited;
  ShowClient;
end;

procedure TfrmClientSelect.RzButton1Click(Sender: TObject);
begin
  inherited;

       qryClient.Close;
       qryClient.SQL.Clear;
      qryClient.SQL.Text:='select * from tb_client where clienttype=:clienttype';
      qryClient.Parameters.ParamByName('clienttype').Value:=FClientType;
       qryClient.SQL.Add(' and clientname like :clientname');
      qryClient.Parameters.ParamByName('clientname').Value:='%' + RzEdit1.Text + '%';
      qryClient.Open;


end;

function TfrmClientSelect.CreateEditForm: TWSEditForm;
begin
    Result:=TfrmProviderEdit.Create(nil);
end;

end.
